/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aptech.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Winner
 */
@Entity
@Table(name = "tblOrderDetail")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TblOrderDetail.findAll", query = "SELECT t FROM TblOrderDetail t"),
    @NamedQuery(name = "TblOrderDetail.findByOdID", query = "SELECT t FROM TblOrderDetail t WHERE t.tblOrderDetailPK.odID = :odID"),
    @NamedQuery(name = "TblOrderDetail.findByElID", query = "SELECT t FROM TblOrderDetail t WHERE t.tblOrderDetailPK.elID = :elID"),
    @NamedQuery(name = "TblOrderDetail.findByOddQuantity", query = "SELECT t FROM TblOrderDetail t WHERE t.oddQuantity = :oddQuantity"),
    @NamedQuery(name = "TblOrderDetail.findByOddPrice", query = "SELECT t FROM TblOrderDetail t WHERE t.oddPrice = :oddPrice")})
public class TblOrderDetail implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TblOrderDetailPK tblOrderDetailPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "oddQuantity")
    private int oddQuantity;
    @Basic(optional = false)
    @NotNull
    @Column(name = "oddPrice")
    private double oddPrice;
    @JoinColumn(name = "odID", referencedColumnName = "odID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private TblOrder tblOrder;
    @JoinColumn(name = "elID", referencedColumnName = "elID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private TblElevation tblElevation;

    public TblOrderDetail() {
    }

    public TblOrderDetail(TblOrderDetailPK tblOrderDetailPK) {
        this.tblOrderDetailPK = tblOrderDetailPK;
    }

    public TblOrderDetail(TblOrderDetailPK tblOrderDetailPK, int oddQuantity, double oddPrice) {
        this.tblOrderDetailPK = tblOrderDetailPK;
        this.oddQuantity = oddQuantity;
        this.oddPrice = oddPrice;
    }

    public TblOrderDetail(int odID, int elID) {
        this.tblOrderDetailPK = new TblOrderDetailPK(odID, elID);
    }

    public TblOrderDetailPK getTblOrderDetailPK() {
        return tblOrderDetailPK;
    }

    public void setTblOrderDetailPK(TblOrderDetailPK tblOrderDetailPK) {
        this.tblOrderDetailPK = tblOrderDetailPK;
    }

    public int getOddQuantity() {
        return oddQuantity;
    }

    public void setOddQuantity(int oddQuantity) {
        this.oddQuantity = oddQuantity;
    }

    public double getOddPrice() {
        return oddPrice;
    }

    public void setOddPrice(double oddPrice) {
        this.oddPrice = oddPrice;
    }

    public TblOrder getTblOrder() {
        return tblOrder;
    }

    public void setTblOrder(TblOrder tblOrder) {
        this.tblOrder = tblOrder;
    }

    public TblElevation getTblElevation() {
        return tblElevation;
    }

    public void setTblElevation(TblElevation tblElevation) {
        this.tblElevation = tblElevation;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tblOrderDetailPK != null ? tblOrderDetailPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblOrderDetail)) {
            return false;
        }
        TblOrderDetail other = (TblOrderDetail) object;
        if ((this.tblOrderDetailPK == null && other.tblOrderDetailPK != null) || (this.tblOrderDetailPK != null && !this.tblOrderDetailPK.equals(other.tblOrderDetailPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.aptech.entities.TblOrderDetail[ tblOrderDetailPK=" + tblOrderDetailPK + " ]";
    }
}
